﻿using THE_WIND_RISES.Common.Dtos;
using THE_WIND_RISES.Common.Domans.Produce.Resources;
using MediatR;
using Org.BouncyCastle.Asn1.Ocsp;
using SlaughterItem.Common.Infrastructures.Interfaces;
using THE_WIND_RISES.Common.Domans.BasicInformation.Materials;
using Return.Enum;
using Production_Get.API.Infrastructures.Interfaces;

namespace Production_Get.API.Application.MaterialManagement
{
    public class MaterialSeachHandler:IRequestHandler<MaterialSeachCommon,Result>
    {
        private readonly IBaseRepositoryGet<ItemServe> ItemServeRepository;
        public MaterialSeachHandler(IBaseRepositoryGet<ItemServe> itemServeRepository)
        {
            ItemServeRepository = itemServeRepository;
        }

        public async Task<Result> Handle(MaterialSeachCommon request, CancellationToken cancellationToken)
        {
            var result = new Result() { Code = (int)CommonErrorCodes.Search };
            string sql = "SELECT * FROM ItemServe";
            var list = ItemServeRepository.GetAll(sql, default).ToList();
            if (list != null)
            {
                result.Code = (int)CommonErrorCodes.Success;
                result.Data = list;
                result.Msg = "显示成功";
            }

            return result;
        }
    }
}
